package com.qing.mapper;

import com.qing.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

public class UserMapperImpl implements UserMapper{

    private SqlSessionTemplate sqlSession;

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    @Override
    public List<User> selectUserAll() {

        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        User user = new User(5,"小王","123456");

        mapper.addUser(user);
        mapper.deleteUser(4);


        return mapper.selectUserAll();
    }

    @Override
    public int addUser(User user) {
        return sqlSession.getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return sqlSession.getMapper(UserMapper.class).deleteUser(id);
    }
}
